#include <iostream>
#include <vector>
using namespace std;

int main() {
    int year, month, day;
    cin >> year >> month >> day;

    vector<int> months_days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) // 判断是否为闰年
        months_days[2] = 29;
    
    int days = 0;
    for(int i = 1; i <= month; i++)
    {
        if(i == month)
        {
            days += day;
            break;
        }
        days += months_days[i];
    }

    cout << days << endl;

    return 0;
}